﻿using System.Data;

namespace DAL
{
    public static class DalExpenditureReason
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetExpenditureReason(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_ExpenditureReason_Get");
        }
        public static DataTable GetExpenditureReasonEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID", id);
            return Cls.GetData("sp_ExpenditureReason_Get_Edit");
        }
        public static bool GetExpenditureReasonCheck(EtExpenditureReason obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID", obj.ID);
            obj.Msg = Cls.ExecuteNonQueryOutput("sp_ReceiptReason_CheckActive", "@Msg");
            return true;
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool InsertExpenditureReason(EtExpenditureReason obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ReceiptReasonCode", obj.ReceiptReasonCode);
            Cls.AddParameter("@ReceiptReasonName", obj.ReceiptReasonName);
            Cls.AddParameter("@Debt", obj.Debt);
            Cls.AddParameter("@Have", obj.Have);
            Cls.AddParameter("@Note", obj.Note);
            Cls.AddParameter("@IsActive", obj.IsActive);
            return Cls.ExecuteNonQuery("sp_ExpenditureReason_Insert");
        }
        public static bool UpdateExpenditureReason(EtExpenditureReason obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID", obj.ID);
            Cls.AddParameter("@ReceiptReasonCode", obj.ReceiptReasonCode);
            Cls.AddParameter("@ReceiptReasonName", obj.ReceiptReasonName);
            Cls.AddParameter("@Debt", obj.Debt);
            Cls.AddParameter("@Have", obj.Have);
            Cls.AddParameter("@Note", obj.Note);
            Cls.AddParameter("@IsActive", obj.IsActive);
            return Cls.ExecuteNonQuery("sp_ExpenditureReason_Update");
        }
        public static bool DeleteExpenditureReason(EtExpenditureReason obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID", obj.ID);
            obj.Msg = Cls.ExecuteNonQueryOutput("sp_ExpenditureReason_Delete", "@Msg");
            return true;
        }
        #endregion
    }
    public class EtExpenditureReason
    {
        public int ID { get; set; }
        public string ReceiptReasonCode { get; set; }
        public string ReceiptReasonName { get; set; }
        public int? Debt { get; set; }
        public int? Have { get; set; }
        public string Note { get; set; }
        public int Msg { get; set; }
        public bool IsActive { get; set; }
    }
}